﻿Imports System.Data.OleDb

Public Class CompanyDAO
    Public Function Company_Lookup() As DataSet
        Return objConnectionDAO.ExecuteStoreprocedure("spTDT_Company_Lookup", Nothing)
    End Function

    Public Function Company_List() As DataSet
        Return objConnectionDAO.ExecuteStoreprocedure("spTDT_Company_List", Nothing)
    End Function

    Public Function Company_Delete(ByVal CompanyID As Integer) As Boolean
        Dim para(1) As OleDbParameter

        para(0) = New OleDbParameter("@CompanyID", CompanyID)
        para(0).OleDbType = OleDbType.Integer

        para(1) = New OleDbParameter("@Success", OleDbType.Boolean)
        para(1).Direction = ParameterDirection.Output

        objConnectionDAO.ExecuteStoreprocedureNoneReturn("spTDT_Company_Delete", para)
        Return para(1).Value
    End Function

    Public Function Company_Select(ByVal CompanyID As Integer) As DataSet
        Dim para(0) As OleDbParameter

        para(0) = New OleDbParameter("@CompanyID", CompanyID)
        para(0).OleDbType = OleDbType.Integer

        Return objConnectionDAO.ExecuteStoreprocedure("spTDT_Company_Select", para)
    End Function

    Public Function Company_Insert(ByVal CompanyName As String, _
                                   ByVal Address As String, _
                                   ByVal TelephoneNumber1 As String, _
                                   ByVal TelephoneNumber2 As String, _
                                   ByVal MobilephoneNumber As String, _
                                   ByVal Fax As String, _
                                   ByVal Email As String, _
                                   ByVal Website As String, _
                                   ByVal Notes As String, _
                                   ByVal ActiveInd As Boolean, _
                                   ByVal CreatedBy As String, _
                                   ByVal CreatedOn As Date, _
                                   ByVal ModifiedBy As String, _
                                   ByVal ModifiedOn As Date, _
                                   ByVal TaxNumber As String) As Boolean
        Dim para(14) As OleDbParameter

        para(0) = New OleDbParameter("@CompanyName", CompanyName)
        para(0).OleDbType = OleDbType.VarWChar

        para(1) = New OleDbParameter("@Address", Address)
        para(1).OleDbType = OleDbType.VarWChar

        para(2) = New OleDbParameter("@TelephoneNumber1", TelephoneNumber1)
        para(2).OleDbType = OleDbType.VarWChar

        para(3) = New OleDbParameter("@TelephoneNumber2", TelephoneNumber2)
        para(3).OleDbType = OleDbType.VarWChar

        para(4) = New OleDbParameter("@MobilephoneNumber", MobilephoneNumber)
        para(4).OleDbType = OleDbType.VarWChar

        para(5) = New OleDbParameter("@Fax", Fax)
        para(5).OleDbType = OleDbType.VarWChar

        para(6) = New OleDbParameter("@Email", Email)
        para(6).OleDbType = OleDbType.VarWChar

        para(7) = New OleDbParameter("@Website", Website)
        para(7).OleDbType = OleDbType.VarWChar

        para(8) = New OleDbParameter("@Notes", Notes)
        para(8).OleDbType = OleDbType.VarWChar

        para(9) = New OleDbParameter("@ActiveInd", ActiveInd)
        para(9).OleDbType = OleDbType.Boolean

        para(10) = New OleDbParameter("@CreatedBy", CreatedBy)
        para(10).OleDbType = OleDbType.VarWChar

        para(11) = New OleDbParameter("@CreatedOn", CreatedOn)
        para(11).OleDbType = OleDbType.Date

        para(12) = New OleDbParameter("@ModifiedBy", ModifiedBy)
        para(12).OleDbType = OleDbType.VarWChar

        para(13) = New OleDbParameter("@ModifiedOn", ModifiedOn)
        para(13).OleDbType = OleDbType.Date

        para(14) = New OleDbParameter("@TaxNumber", TaxNumber)
        para(14).OleDbType = OleDbType.VarWChar

        Return objConnectionDAO.ExecuteStoreprocedureNoneReturn("spTDT_Company_Insert", para)
    End Function

    Public Function Company_Update(ByVal CompanyID As Integer, _
                                  ByVal CompanyName As String, _
                                   ByVal Address As String, _
                                   ByVal TelephoneNumber1 As String, _
                                   ByVal TelephoneNumber2 As String, _
                                   ByVal MobilephoneNumber As String, _
                                   ByVal Fax As String, _
                                   ByVal Email As String, _
                                   ByVal Website As String, _
                                   ByVal Notes As String, _
                                   ByVal ActiveInd As Boolean, _
                                   ByVal CreatedBy As String, _
                                   ByVal CreatedOn As Date, _
                                   ByVal ModifiedBy As String, _
                                   ByVal ModifiedOn As Date, _
                                   ByVal TaxNumber As String) As Boolean
        Dim para(15) As OleDbParameter

        para(0) = New OleDbParameter("@CompanyID", CompanyID)
        para(0).OleDbType = OleDbType.Integer

        para(1) = New OleDbParameter("@CompanyName", CompanyName)
        para(1).OleDbType = OleDbType.VarWChar

        para(2) = New OleDbParameter("@Address", Address)
        para(2).OleDbType = OleDbType.VarWChar

        para(3) = New OleDbParameter("@TelephoneNumber1", TelephoneNumber1)
        para(3).OleDbType = OleDbType.VarWChar

        para(4) = New OleDbParameter("@TelephoneNumber2", TelephoneNumber2)
        para(4).OleDbType = OleDbType.VarWChar

        para(5) = New OleDbParameter("@MobilephoneNumber", MobilephoneNumber)
        para(5).OleDbType = OleDbType.VarWChar

        para(6) = New OleDbParameter("@Fax", Fax)
        para(6).OleDbType = OleDbType.VarWChar

        para(7) = New OleDbParameter("@Email", Email)
        para(7).OleDbType = OleDbType.VarWChar

        para(8) = New OleDbParameter("@Website", Website)
        para(8).OleDbType = OleDbType.VarWChar

        para(9) = New OleDbParameter("@Notes", Notes)
        para(9).OleDbType = OleDbType.VarWChar

        para(10) = New OleDbParameter("@ActiveInd", ActiveInd)
        para(10).OleDbType = OleDbType.Boolean

        para(11) = New OleDbParameter("@CreatedBy", CreatedBy)
        para(11).OleDbType = OleDbType.VarWChar

        para(12) = New OleDbParameter("@CreatedOn", CreatedOn)
        para(12).OleDbType = OleDbType.Date

        para(13) = New OleDbParameter("@ModifiedBy", ModifiedBy)
        para(13).OleDbType = OleDbType.VarWChar

        para(14) = New OleDbParameter("@ModifiedOn", ModifiedOn)
        para(14).OleDbType = OleDbType.Date

        para(15) = New OleDbParameter("@TaxNumber", TaxNumber)
        para(15).OleDbType = OleDbType.VarWChar

        Return objConnectionDAO.ExecuteStoreprocedureNoneReturn("spTDT_Company_Update", para)
    End Function




End Class
